import javax.swing.JPanel;

import java.awt.Font;
import java.awt.Frame;
import java.awt.BorderLayout;
import javax.swing.JDialog;
import javax.swing.JLabel;
import java.awt.Dimension;
import java.awt.Point;
import javax.swing.JButton;
import java.awt.Rectangle;

/**
 * 
 * Choose membership type
 *
 */
public class ChooseMemberShipGUI extends JDialog {

	private static final long serialVersionUID = 1L;
	/** panel for the window */
	private JPanel jContentPane = null;
	/** choose label */
	private JLabel choose = null;
	/** yearly membership button */
	private JButton year = null;
	/** monthly membership button */
	private JButton month = null;
	/** holds old expiration date of membership */
	private String[] temp;
	/** month label */
	private JLabel monthly = null;
	/** year label */
	private JLabel yearly = null;
	/**
	 * @param owner
	 */
	public ChooseMemberShipGUI(Frame owner,String[] date) {
		super(owner);
		temp=date;
		initialize();
		
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(403, 259);
		this.setContentPane(getJContentPane());
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			yearly = new JLabel();
			yearly.setBounds(new Rectangle(20, 114, 331, 45));
			yearly.setText("Yearly -  365   Days from today (1000$)");
			monthly = new JLabel();
			monthly.setBounds(new Rectangle(21, 69, 334, 37));
			monthly.setText("Monthly -  30   Days from today (200$)");
			monthly.setFont(new Font(Font.SANS_SERIF ,Font.PLAIN,20));
			yearly.setFont(new Font(Font.SANS_SERIF ,Font.PLAIN,20));
			choose = new JLabel();
			choose.setText("Choose Monthly or Yearly Membership");
			choose.setFont(new Font("David" ,Font.BOLD,22));
			choose.setLocation(new Point(5, 14));
			choose.setSize(new Dimension(379, 44));
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(choose, BorderLayout.NORTH);
			jContentPane.add(getYear(), null);
			jContentPane.add(getMonth(), null);
			jContentPane.add(monthly, null);
			jContentPane.add(yearly, null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes year	and set an action listener for it
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getYear() {
		if (year == null) {
			year = new JButton("Yearly");
			year.setBounds(new Rectangle(228, 171, 109, 42));
			year.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					Main.cart.isYearly=true;
					Main.cart.registerUpdatedMembership(temp);
				}
			});
		}
		return year;
	}

	/**
	 * This method initializes month and sets a listener for it	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getMonth() {
		if (month == null) {
			month = new JButton("Monthly");
			month.setBounds(new Rectangle(33, 172, 108, 40));
			month.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
					Main.cart.isYearly=false;
					Main.cart.registerUpdatedMembership(temp);
				}
			});
		}
		return month;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
